package com.cjm.algorithm.dp;

public class Ti474 {
    public static void main(String[] args) {
        String[] x = new String[]{"10","0001","111001","1","0"};
        Ti474 ti474 = new Ti474();
        System.err.println(ti474.findMaxForm(x, 5, 3));
    }

    public int findMaxForm(String[] strs, int m, int n) {
        int[][] dp = new int[m + 1][n + 1];
        for (String str : strs) {
            int oneNum = 0, zero = 0;
            char[] charArray = str.toCharArray();
            for (char c : charArray) {
                if ('0' == c) zero++;
                else oneNum++;
            }
            for (int i = m; i >= zero; i--) {
                for (int j = n; j >= oneNum; j--) {
                    dp[i][j] = Math.max(dp[i][j], dp[i - zero][j - oneNum] + 1);
                }
            }
        }
        return dp[m][n];
    }
}
